
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User just_user = (User)session.getAttribute("LoginUser");

String power_enable_id1 = "10006";
String power_enable_id2 = "10106";
if (!just_user.hasPower(power_enable_id1)&&(!just_user.hasPower(power_enable_id2))) {
	out.println(strNoPowerInfo); 
	return;
}
String nowyear = new SimpleDateFormat("yyyy").format(Calendar.getInstance().getTime());
String nowmonth = new SimpleDateFormat("MM").format(Calendar.getInstance().getTime());
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    
<title>My JSP 'techcontract_add.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link href="style/main.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/common.js"></script>
<%
 String strErr = "";

int conid       = ParamUtils.getIntParameter(request,"conid",0);

String spartfee          = ParamUtils.getParameter(request,"spartfee","0.00");
String outefee             = ParamUtils.getParameter(request,"outefee","0.00");
 String cmd = ParamUtils.getParameter(request,"cmd","");
String year = ParamUtils.getParameter(request,"year",nowyear);
String month = ParamUtils.getParameter(request,"month",nowmonth);

if (cmd.trim().equals("insert")) {
	if (strErr.trim().equals("") && conid==0) {
		strErr = "合同编号不能为空!";
	}
	
	
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(spartfee);
		}
		catch(Exception ex) {
			strErr = "备件成本数值输入错误!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(outefee);
		}
		catch(Exception ex) {
			strErr = "外部人员技术成本输入错误!";
		}
	}
	
	

	if (strErr.trim().equals("")) {
	
		Pala pal = new Pala("conid");		
		pal.setConid(conid);
	
		pal.setCreateman(just_user.getId());
		
		//.setSpartfee(Double.parseDouble( spartfee));
		//pal.setOutefee(Double.parseDouble( outefee));

		pal.setY( Integer.parseInt(year));
		pal.setM( Integer.parseInt(month));
	
		pal.insert();
		
	if (pal.hasErr()) strErr = pal.getErrHtml();
                
	}
}
      
    
    %>
   <script language="javascript" >
   function clk_submit() {
	var oForm = document.operatorForm;
	oForm.cmd.value = "insert";
	return true;
}
   function clk_goback() {
	history.back();
}
</script>
</head>

<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
     <form name="operatorForm" method="post" onSubmit="return clk_submit();">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="100" align="center" valign="top" style="padding-top:10px;padding-bottom:10px;">
            <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
			
			 <tr>
                <td height="24" colspan="7" bgcolor="#EDEDF0" style="padding-left:10px;">
                提示：<font color="red">*</font> 号为必填项，请您认真填写                </td>
              </tr>
               <%if (!strErr.trim().equals("")) {%>
              <tr> 
                <td height="24" colspan="7" bgcolor="#D7D7DB" style="padding-left:10px;">
                  错误提示：
                 
                  <font color=red><%=strErr%></font>                </td>
              </tr>
              <%}%>
              
              <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>合同信息</strong></font>  </td>
              </tr>
              <tr> 
                <td width="17%" height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">
                <span style="padding-left:5px;"><font color="red">*</font></span>合同编号：</td>
                <td width="83%" colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                  <input name="conid" type="text" value="<%=conid%>" size="25" maxlength="30" readonly="readonly" style="background-color:#EDEDE8">
                   &nbsp;&nbsp;</td>
              </tr>
			  <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >备件成本：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="spartfee" type="text" value="<%=FormatNum.formatNumber(Double.parseDouble(spartfee))%>" id="spartfee" size="25" maxlength="10" readonly="readonly" style="background-color:#EDEDE8"> ￥
                   
                   </td>
              </tr> 
               <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >外部人员技术成本：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="outefee" type="text" value="<%=FormatNum.formatNumber(Double.parseDouble(outefee))%>" id="outefee" size="25" maxlength="10" readonly="readonly" style="background-color:#EDEDE8"> ￥
                   </td>
              </tr> 
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"><p>核算年月：</p>   
				 </td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				  <select name="year">
		  <option value="" <%if (year.trim().equals("")){%> selected<%}%>>全部</option>
                    <%
                    int yearNum = Calendar.getInstance().get(Calendar.YEAR)+4;
                    for(int i= yearNum - 10;i <= yearNum;i++) {
                    %>
                    <option value="<%=i%>"<%if (year.trim().equals(i+"")){%> selected<%}%>><%=i%></option>
                    <%}%>
                  </select> 年 &nbsp; 
                  <select name="month">
                  <option value="" <%if (month.trim().equals("")){%> selected<%}%>>全部</option>
                    <option value="01"<%if (month.trim().equals("01")){%> selected<%}%>>1</option>
                    <option value="02"<%if (month.trim().equals("02")){%> selected<%}%>>2</option>
                    <option value="03"<%if (month.trim().equals("03")){%> selected<%}%>>3</option>
                    <option value="04"<%if (month.trim().equals("04")){%> selected<%}%>>4</option>
                    <option value="05"<%if (month.trim().equals("05")){%> selected<%}%>>5</option>
                    <option value="06"<%if (month.trim().equals("06")){%> selected<%}%>>6</option>
                    <option value="07"<%if (month.trim().equals("07")){%> selected<%}%>>7</option>
                    <option value="08"<%if (month.trim().equals("08")){%> selected<%}%>>8</option>
                    <option value="09"<%if (month.trim().equals("09")){%> selected<%}%>>9</option>
                    <option value="10"<%if (month.trim().equals("10")){%> selected<%}%>>10</option>
                    <option value="11"<%if (month.trim().equals("11")){%> selected<%}%>>11</option>
                    <option value="12"<%if (month.trim().equals("12")){%> selected<%}%>>12</option>
                  </select> &nbsp;月
                  </td>
                </tr>
              <tr> 
                <td bgcolor="#EDEDF0" colspan="7" align="center">
                  <input type="submit" name="submit" value="提 交" class="inputButton"> 
                  <input type="reset" name="reset" value="重 写" class="inputButton">  
                    <input type="button" name="back" value="返回" onclick="clk_goback();" class="inputButton">         
                  <input type="hidden" name="cmd" value="">              </td>
              </tr>
            </table>
          </td>
        </tr>
       
      </table>
      </form>
    </td>
  </tr>
</table>

<%if (cmd.equals("insert") && strErr.trim().equals("")){%>
<script language="javascript">
alert("信息添加成功系统将返回首页!");
location.href="../incontract_mgt/incon_detail.jsp?conid="+document.operatorForm.conid.value;
</script>
<%}%>

</body>
</html>
